// /*
//  * @Author: WanYiMing
//  * @Date:2024-07-08-16:22
//  * @Description:
//  */

using Code.GameLogic.XianJian.Controller;
using Code.GameLogic.XianJian.XianJianBehavior.Action;
using UnityEngine;

namespace Code.GameLogic.XianJian.XianJianBehavior.Behavior
{
    public class LockAct2:AbsXianJianBehavior
    {
        private ActLockTarget _actLockTarget;
        private ActLockingAttackTarget _lockingAttackTarget;
        
        private GameObject _lockGameObject;
        
        
        public override bool IsBehavior()
        {
            return _lockGameObject is not null;
        }

        public override void AutoBehavior()
        {
            _actLockTarget.LockAtTigerBox(this.XianJianController.gameObject, _lockGameObject.gameObject);
            _lockingAttackTarget.Attack(_lockGameObject,"ActionSpaceLine");
        }

        public override void TigerBehavior(GameObject gameObject, ObjectBehaviorEnum objectBehavior)
        {
            switch (objectBehavior)
            {
                case ObjectBehaviorEnum.InView:
                    _lockGameObject ??= gameObject;
                    break;
                case ObjectBehaviorEnum.OutView:
                    if (_lockGameObject == gameObject) _lockGameObject = null;
                    break;
                case ObjectBehaviorEnum.Death:
                    if (_lockGameObject == gameObject) _lockGameObject = null;
                    break;
            }
        }

        
        public override void InitBehavior(XianJianController xianJianController)
        {
            _actLockTarget = new ActLockTarget();
            _lockingAttackTarget = new ActLockingAttackTarget(xianJianController);
        }
    }
}